layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 拣货单明细表管理
     */
    var StorageOutDetailed = {
        tableId: "storageOutDetailedTable"
    };

    /**
     * 初始化表格的列
     */
    StorageOutDetailed.initColumn = function () {
        return [[
            {type: 'checkbox', fixed: 'left'},
            {field: 'id', hide: true, title: '主键id'},
            {field: 'storageOutNumber', sort: true, title: '出库订单编号',fixed: 'left',totalRowText: '合计：'},
            {field: 'trayNumber', sort: true, title: '托盘编号',fixed: 'left'},
            {field: 'storagePostionNumber', sort: true, title: '库位编号'},
            {field: 'storageGoodscode', sort: true, title: '商品编号'},
            {field: 'storageGoodsId', sort: true, hide:true, title: '商品id'},
            {field: 'storageGoodsname', sort: true, title: '商品名称'},
            {field: 'storagePutbalenum', sort: true, title: '大包数',totalRow: true},
            {field: 'storageNumber', sort: true, title: '出库数量',totalRow: true},
            {field: 'storageWeight', sort: true, title: '重量',totalRow: true},
            {field: 'storageVolume', sort: true, title: '体积',totalRow: true},
            {field: 'storagePrice', sort: true, title: '单价',totalRow: true},
            {field: 'storageMoney', sort: true, title: '金额',totalRow: true},
            {field: 'storageBatchnumber', sort: true, title: '批号'},
            {field: 'storageOutStatus', sort: true, title: '出库状态'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    StorageOutDetailed.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(StorageOutDetailed.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
                 // 搜索按钮点击事件
                 $('#btnSearch').click(function () {
                     StorageOutDetailed.search();
                 });
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + StorageOutDetailed.tableId,
        url: Feng.ctxPath + '/storageOutDetailed/getmarklist?mark='+$("#mark").val()+"&storageOutNumber="+$("#storageOutNumber").val(),
        page: true,
        limit: 20,
        height: "full-60",
        toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        cols: StorageOutDetailed.initColumn(),
        totalRow: true//开启合计行
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        StorageOutDetailed.search();
    });

});
